<template>
  <!-- 系统字典 首页 -->
  <el-dialog
    v-el-drag-dialog
    title="字典详情"
    :visible.sync="crud.status.info > 0"
    :before-close="crud.closeInfo"
  >
    <div class="info_detail_dialog__body">
      <el-card v-loading="crud.infoLoading" class="box-card" shadow="hover">
        <el-row :gutter="20">
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">详情ID: </div><div class="info_detail_value">{{ info.id }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">字典标识: </div><div class="info_detail_value">{{ info.dictLabel || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">索引值: </div><div class="info_detail_value">{{ info.key || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">索引值对应名称: </div><div class="info_detail_value">{{ info.value || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">排序: </div><div class="info_detail_value">{{ info.paixu || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">上级字典: </div><div class="info_detail_value">{{ info._parentInfo.value || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">描述: </div><div class="info_detail_value">{{ info.description || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">字典类型 : </div><div class="info_detail_value">{{ dict.label.dict_type[info.dictType] || '未知字典码:'+info.dictType }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">状态: </div><div class="info_detail_value">{{ dict.label.common_status[info.status] || '未知字典码:'+info.status }}</div></el-col>

          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">创建时间:</div><div class="info_detail_value">{{ info.createTime || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">创建人:</div><div class="info_detail_value">{{ info.createUserName || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">最后一次修改时间:</div><div class="info_detail_value">{{ info.updateTime || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">最后一次修改人:</div><div class="info_detail_value">{{ info.updateUserName || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">是否被删除数据:</div><div class="info_detail_value">{{ info.isDel?'是':'否' }}</div></el-col>

        </el-row>

      </el-card>
    </div>
  </el-dialog>
</template>

<script>
import elDragDialog from '@/directive/el-drag-dialog'
import CRUD, { info } from '@crud/crud'
// 系统字典 - model
const defaultInfo = {
  id: null, //
  dictLabel: null, // 字典标识（所属字典）
  key: null, // 索引值
  value: null, // 索引值对应名称
  paixu: 1,
  parentId: '0',
  description: null, // 描述
  dictType: null, // 字典类型 默认0：字典，1：字典详情
  depId: null, // 部门id
  status: 1,
  lockVersion: 0,
  createTime: null,
  createUserName: null,
  updateTime: null,
  updateUserName: null,
  isDel: 0,
  _parentInfo: {}
}
export default {
  directives: { elDragDialog },
  mixins: [info(defaultInfo)],
  dicts: ['dict_type', 'common_status'],
  data() {
    return {
    }
  },
  mounted() {
  },
  methods: {
    [CRUD.HOOK.afterDoInfo]() {
      console.log(this.dict.label)
      if (this.info.parentId && this.info.parentId !== '0') {
        this.crud.crudMethod.info(this.info.parentId).then(res => {
          this.info._parentInfo = res.data
        }).catch((error) => {
          this.crud.notify('未找到上级信息', CRUD.NOTIFICATION_TYPE.ERROR)
          console.log(error)
        })
      }

      return true
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
